package com.dobby.pea.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dobby.pea.entity.tbAddressBook;
import com.dobby.pea.entity.tbShoppingCart;
import com.dobby.pea.mapper.AddressBookMapper;
import org.springframework.stereotype.Service;
import com.dobby.pea.service.AddressBookService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AddressBookServiceImpl extends ServiceImpl<AddressBookMapper, tbAddressBook> implements AddressBookService {

    @Transactional
    public tbAddressBook DefaultAddressBook(Long userId) {
        LambdaQueryWrapper<tbAddressBook> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(tbAddressBook::getUserId,userId);
        queryWrapper.eq(tbAddressBook::getIsDefault,1);
        tbAddressBook one = this.getOne(queryWrapper);
        return one;
    }
}
